import {Component, OnInit, Input, OnChanges, Output, EventEmitter} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';

@Component({
    selector: 'kylin-set-point-style',
    templateUrl: './set-point-style.component.html',
    styleUrls: ['./set-point-style.component.less']
})
export class SetPointStyleComponent implements OnInit, OnChanges {
    pointStyleForm: FormGroup;
    @Input() showSetPointComponent;
    size = '小';
    color = '#ffcc33';
    @Output() setPointStyleFun = new EventEmitter<any>();
    @Output() hideComponent = new EventEmitter<any>();
    @Input() selectcolor;
    constructor(private fb: FormBuilder) {
    }
    ngOnChanges () {
        if (this.selectcolor === '#ffcc33' || this.selectcolor === '') {
            this.color = '#ffcc33'
        } else {
            this.color = this.selectcolor
        }
    }

    ngOnInit() {
        this.getStyleData()
    }

    getStyleData() {
        this.pointStyleForm = this.fb.group({
            pointColor: ['', [Validators.required]],
        })
    }

    // 取消
    handleAttrForm() {
        this.showSetPointComponent = false;
        this.hideComponent.emit(false);
    }

    // 确定
    submitAttrForm() {
        this.showSetPointComponent = false;
        this.setPointStyleFun.emit(this.pointStyleForm.value);
    }

}
